﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Panel.Master" Inherits="System.Web.Mvc.ViewPage<IList<Prodma.DataAccess.Models.ViewModels.OfficeVm>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=System.Configuration.ConfigurationManager.AppSettings["pageTitle"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div class="listHeader">
        <img src="../../Images/ListImages/officelist.png" alt="" class="listHeaderIco" />
        <div class="listHeaderText">İşyeri Yöneticisi</div>
        
        <div class="listHeaderMenuBox">
            <% Html.RenderPartial("/views/shared/userControls/navigation.ascx",
                   Prodma.DataAccess.Authorization.Authorization.GetNavigation("office", 20));%>
        </div>
    </div>
    
    <div class="listFindBar">
        <% Html.RenderPartial("/views/shared/userControls/find.ascx",
               new Prodma.DataAccess.Models.UserControlViewModels.FindVm() { View = "office" });%>
    </div>
    
    <div class="listTitleContainer">
        <div class="listTitleCenter-50">#</div>
        <div class="listTitleCenter-50"><input type="checkbox" id="chk" name="chk" /></div>
        <div class="listTitleLeft-200">Ad</div>
        <div class="listTitleCenter-150">Birim</div>
        <div class="listTitleCenter-150">Durum</div>
        <div class="listTitleCenter-50">ID</div>
    </div>
    
    <div class="listRowContainer">
    <% int totalCount = Convert.ToInt32(ViewData["totalRowCount"]) ; %>
    <!-- Bölümlere göre ayrıştırma -->
    <% List<int> officeCounts = (List<int>)ViewData["officeCounts"]; %>
    <!-- Listeleme -->
    <% int counter = 1; %>
    <% int seperatorCounter = 0; %>
    <% int same = 0; %>
    <% foreach (int unit in (IList<int>)ViewData["unitList"]) %>
    <% { %>
         <% foreach (Prodma.DataAccess.Models.ViewModels.OfficeVm office in ViewData.Model) %>
         <% { %>
              <% if (Convert.ToInt32(unit) == office.Unit.Id) %>
              <% { %>
                   <% same++; %>
                   <% if (counter % 2 != 0) %>
                   <% { %>
                       <div class="listRow1">
                           <div class="listColumnCenter-50"><%=counter %></div>                      
                           <div class="listColumnCenter-50"><input type="checkbox" id='chk<%=office.Id %>' name="chkSelect" /></div>
                           <div class="listColumnLeft-200">
                             <a href='/office/edit/?id=<%=office.Id %>&unit=<%=office.Unit.Id %>' class="listSelectItemBold">
                                 <%=office.Name%>
                             </a>
                           </div>
                           <div class="listColumnCenter-150"><%=office.Unit.Name%></div>
                           <div class="listColumnCenter-150"><%=office.State.Name%></div>
                           <div class="listColumnCenter-50"><%=office.Id%></div>
                       </div>
                  <% } %>
                  <% else %>
                  <% { %>
                       <div class="listRow2">
                           <div class="listColumnCenter-50"><%=counter %></div>                      
                           <div class="listColumnCenter-50"><input type="checkbox" id='chk<%=office.Id %>' name="chkSelect" /></div>
                           <div class="listColumnLeft-200">
                             <a href='/office/edit/?id=<%=office.Id %>&unit=<%=office.Unit.Id %>' class="listSelectItemBold">
                                 <%=office.Name%>
                             </a>
                           </div>
                           <div class="listColumnCenter-150"><%=office.Unit.Name%></div>
                           <div class="listColumnCenter-150"><%=office.State.Name%></div>
                           <div class="listColumnCenter-50"><%=office.Id%></div>
                       </div>
                   <% } %>
                   <% counter++; %>
              <% } // if Unit.Id == Office.Unit.Id %>
         <% } // ForEach Office %>
         <% seperatorCounter++; %>
    <% } // ForEach Unit %>
    </div>

    <script type="text/javascript">
        $(function() {
            $('#chk').click(function() {
                $("input[type='checkbox']").attr('checked', $('#chk').is(':checked'));
            });
        });
    </script>

</asp:Content>

